from selenium import webdriver
wd = webdriver.Chrome(r'd:\chromedriver.exe')
wd.implicitly_wait(5)

wd.get('http://cdn1.python3.vip/files/selenium/sample2.html')
#elements = wd.find_elements_by_css_selector('#container > div')
#elements = wd.find_elements_by_css_selector('#layer1 > div')
#elements = wd.find_elements_by_css_selector('#layer1  span')
# wd.find_element_by_class_name('plant')
# print(elements.get_attribute('outerHTML'))
wd.switch_to.frame(wd.find_element_by_css_selector('[src="sample1.html"'))
elements = wd.find_elements_by_css_selector('.animal span')
for element in elements:
    print('-----------')
    print(element.get_attribute('outerHTML'))
#切换到外层
wd.switch_to.default_content()
wd.find_element_by_id('outerbutton').click()

#wd.quit()